package com.forekonw.ceyan1027;

import java.util.Scanner;

/**
 * 1、定义一个点类Point，包含2个成员变量x、y分别表示x和y坐标，2个构造器Point()和Point(intx0,y0),
 * 以及一个movePoint（int dx,int dy）方法实现点的位置移动，创建两个Point对象p1、p2，
 * 分别调用movePoint方法后，打印p1和p2的坐标。[必作题]
 */
public class Point {
    private int x;
    private int y;

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public void movePoint(int dx, int dy){
        this.x += dx;
        this.y += dy;
    }
    public static void main(String[] args) {
            Point point = new Point();
            Scanner input = new Scanner(System.in);
            System.out.println("请输入两个参数:");
            int a = input.nextInt();
            int b = input.nextInt();
            point.setX(a);
            point.setY(b);
            point.movePoint(a,b);
            System.out.println(point.getX()+"---"+point.getY());

            Point p = new Point();
            p.setX(3);
            p.setY(4);
            p.movePoint(3,5);
        System.out.println(p.getX()+"---"+p.getY());
        }
    }



